﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;

namespace zmMoniter
{
    public partial class frmReport : DevExpress.XtraEditors.XtraForm
    {
      #region **************仓面屏幕参数**************
        private double m_xStart;//存储屏幕左下角的实际坐标X
        private double m_yStart;//存储屏幕左下角的实际坐标Y
        private Extent m_Extent;
        private Extent m_MapAllExtent;
        private double m_Blc;//存储屏幕转换比例尺
        private int m_wScreen, m_hScreen;//存储视图屏幕的实际宽度和高度（逻辑坐标）
        public int m_MapMode;
        public int m_OldMapMode;

        private double m_MouseX, m_MouseY;//鼠标移动轨迹
        private bool m_Move;//是否执行移动地图操作
        private bool m_bSZommIn;//是否执行放大地图操作
        private bool m_bZommOut;//是否执行缩小地图操作
        public bool bReady;//是否准备好数据了
        private Point m_Point1, m_Point2;//移动时候的起终点坐标
        private bool m_bLBtnDown = false;
        #endregion
        #region **************变量**************
        private mainForm main = null;
        ArrayList alGraph = new ArrayList();//仓面层面图元数组
        ArrayList alVibGraph = new ArrayList();//振捣图元数组
        ArrayList alTitleGraph = new ArrayList();//仓面层面图元数组
        ArrayList alNonVibrGraph = new ArrayList();//非振捣区域临时点位数组
        DeckGrider grder = null;
        private string sFlag = "";
        public  string sDeckID = "";
        public  string sDeckName = "";
        public  string sLayerID = "";
        public  string sLayerName = "";
        string  sDamBlock = "";
        public  bool bFlash = false;
        private string sEndTime = "";
        
        //覆盖统计
        private double dOverArea = 0;
        private double dNormalArea = 0;
        private double dAbnormalArea = 0;
        private double dInvalidArea = 0;
        private double dTotleArea = 0;
        private int    iVibAllowDepth = 55;
        private float  fVibAllowAngle = 15;
        private int    iVibAllowMinTime = 15;
        private int    iVibAllowMaxTime = 17;
        public  int    iVibAllowOver=30;
        public  int    iVibAllowInterval = 5;
       

        //深度统计
        private float fMaxDepth = -99999;
        private float fMinDepth = 99999;
        private int iDepthSection = 5;
        private int[] Depth = new int[5];

        //时间统计
        private float fMaxTime = -99999;
        private float fMinTime = 99999;
        private int iTimeSection = 5;
        private int[] Time = new int[5];

        //有效统计
        private int[] Qualified = new int[3];
        public int iQualifiedSection = 3;

        
        #endregion
        public  frmReport(mainForm frm)
        {
            InitializeComponent();
            bReady = false;
            m_Extent = new Extent();
            //updateMapExtent();
            m_MapMode = 3;
            m_OldMapMode = 3;
            m_Point1 = new Point(0, 0);
            m_Point2 = new Point(0, 0);
            this.main = frm;
            grder = new DeckGrider();
            grder.setReportDrid();
            grder.setGridLength(0.1);
        }
        public  void setID(string sVID, string sID)
        {
            sDeckID=sVID;
            sLayerID = sID;
        }
        private void setCanvas(double dX, double dY, double dBlc)
        {
            m_xStart = dX;
            m_yStart = dY;
            m_Blc = dBlc;
        }
        private void updateMapExtent()
        {
            m_wScreen = this.Canvas.Width;
            m_hScreen = this.Canvas.Height;
            if (m_wScreen != 0 && m_hScreen != 0)
            {
                bReady = true;

                int iScreenSize = m_wScreen > m_hScreen ? m_hScreen : m_wScreen;
                double dMapWSize = m_Extent.dMaxX - m_Extent.dMinX;
                double dMapHSize = m_Extent.dMaxY - m_Extent.dMinY;
                double dMapSize = dMapWSize > dMapHSize ? dMapWSize : dMapHSize;

                m_Blc =  1.3*dMapSize / iScreenSize;

                if (m_wScreen > m_hScreen)
                {
                    m_xStart = (m_Extent.dMaxX + m_Extent.dMinX) / 2 - m_wScreen / 2 * m_Blc;
                    m_yStart = (m_Extent.dMaxY + m_Extent.dMinY) / 2 - m_hScreen / 2 * m_Blc;
                }
                else
                {
                    m_xStart = (m_Extent.dMaxX + m_Extent.dMinX) / 2 - m_wScreen / 2 * m_Blc;
                    m_yStart = (m_Extent.dMaxY + m_Extent.dMinY) / 2 - m_hScreen / 2 * m_Blc;
                }
            }
        }
        private void addGraph(Graph gObj)
        {
            alGraph.Add(gObj);

        }
        private void clearGraph()
        {
            alGraph.Clear();
            alVibGraph.Clear();
            alTitleGraph.Clear();
            alNonVibrGraph.Clear();
            sDeckID = "";
            sDeckName = "";
            sLayerID = "";
            sLayerName = "";
            sDamBlock = "";
            dNormalArea = 0;
            dAbnormalArea = 0;
            dInvalidArea = 0;
            dTotleArea = 0;
            dOverArea = 0;
            sFlag = "";
            sEndTime = "";


            iVibAllowDepth = 55;
            fVibAllowAngle = 15;
            iVibAllowMinTime = 15;
            iVibAllowMaxTime = 17;

        //深度统计
            fMaxDepth = -99999;
            fMinDepth = 99999;
            
            Depth[0]=Depth[1]=Depth[2]=Depth[3]= Depth[4]=0;

        //时间统计
            fMaxTime = -99999;
            fMinTime = 99999;
            Time[0]=Time[1]=Time[2]=Time[3]= Time[4]=0;
            

        //有效统计
            Qualified[0]=Qualified[1]=Qualified[2]=0;

        }
        private string getDeckTitle(string strDeckName,string strLayerName)
        {
            if (strDeckName == "")
                return "";
            string[] str = strDeckName.Split('-');

            string strDam = str[0];
            string strBlock = str[1];
            string strLayer = str[2];
            string sName = "";
            
            sName += strDam + "#坝段 ";

            if (strBlock == "S")
                sName += "上游坝块 ";
            else
                sName += "下游坝块 ";
            sName += strDeckName + "仓 ";
            sName += "第" + strLayerName + "铺层";
            return sName;


        }
        public  void upDateNonVibr()
        {
            alNonVibrGraph.Clear();
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 非振捣区域.* from 非振捣区域 WHERE 仓面号=" + sDeckID + " AND 层号=" + sLayerID;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            for (int i = 0; i < iCount; i++)
            {
                DataRow dataRow = dt.Rows[i];


                double dArea = -1;
                string sArea = dataRow["面积"].ToString().Trim();
                if (sArea != "")
                    dArea = float.Parse(sArea);

                int iColor = int.Parse(dataRow["显示颜色"].ToString().Trim());
                string strVbtFence = dataRow["非振捣点位"].ToString().Trim();
                double dCenterX = -1;
                double dCenterY = -1;

                NonVibrators nonVibr = new NonVibrators();
                getCenterXY(strVbtFence, ref nonVibr);
                nonVibr.sName = dataRow["名称"].ToString().Trim();
                nonVibr.sID = dataRow["编号"].ToString().Trim();
                nonVibr.sDisc = dataRow["说明"].ToString().Trim();
                nonVibr.iColor = int.Parse(dataRow["显示颜色"].ToString().Trim());
                nonVibr.dArea = dArea;
                nonVibr.setRegion();
                alNonVibrGraph.Add(nonVibr);
            }
        }
        private void getCenterXY(string strVbtFence, ref NonVibrators nonVibr)
        {
            string[] strXYs = strVbtFence.Split(';');
            if (strXYs.Length == 0)
                return;
            double dCenterX=0;
            double dCenterY=0;
            for (int i = 0; i < strXYs.Length; i++)
            {
                string[] sXY = strXYs[i].Split(',');
                if (sXY.Length != 2)
                    continue;
                double dx = double.Parse(sXY[0]);
                double dy = double.Parse(sXY[1]);
                Point pt = new Point(dx, dy);
               
                nonVibr.addPoint(pt);
                dCenterX += dx;
                dCenterY += dy;
            }
            nonVibr.dCenterX = dCenterX * 1.0 / strXYs.Length;
            nonVibr.dCenterY = dCenterY * 1.0 / strXYs.Length;
        }
        private void DoOverLayWork()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 铺层信息表.*,仓面信息.仓面名称,仓面信息.坝段,仓面信息.上下游块,仓面信息.最低高程,仓面信息.最高高程," +
            "仓面信息.振捣边界点,仓面信息.铺层厚度,仓面信息.开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间 " +
            "from 铺层信息表,仓面信息 WHERE 铺层信息表.仓面号=仓面信息.编号 AND 铺层信息表.编号=" + sLayerID + " AND 铺层信息表.仓面号=" + sDeckID;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            DataRow dataRow = dt.Rows[0];
            sDeckName = dataRow["仓面名称"].ToString().Trim();
            sLayerName = dataRow["层编号"].ToString().Trim();
            sDamBlock = sDeckName.Substring(0, sDeckName.LastIndexOf('-'));
            //float fArea = float.Parse(dataRow["剩余未振捣面积"].ToString().Trim());
            float fhMin = float.Parse(dataRow["最低高程"].ToString().Trim());
            float fhMax = float.Parse(dataRow["最高高程"].ToString().Trim());
            string strDeckFence = dataRow["仓面控制点"].ToString().Trim();
            string strVbtFence = dataRow["振捣边界点"].ToString().Trim();
            string strLayerFence = dataRow["层边界控制点"].ToString().Trim();
            string strStartTime = dataRow["开仓时间"].ToString().Trim();
            string strEndTime = dataRow["结束时间"].ToString().Trim();
            sEndTime = strEndTime;
            Graph gObjTitle = new Graph(1, -1);
            gObjTitle.addText(getDeckTitle(sDeckName,sLayerName));
            gObjTitle.setFont(new Font("微软雅黑", 10f));
            alTitleGraph.Add(gObjTitle);

            Graph gObjMaxElv = new Graph(1, -1);
            gObjMaxElv.addText("EL." + fhMax.ToString() + "米");
            gObjMaxElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMaxElv);

            Graph gObjMinElv = new Graph(1, -1);
            gObjMinElv.addText("EL." + fhMin.ToString() + "米");
            gObjMinElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMinElv);

            Graph gObjStartDate = new Graph(1, -1);
                        
            gObjStartDate.addText("开始:" + strStartTime);
            gObjStartDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjStartDate);

            Graph gObjEndDate = new Graph(1, -1);
           
            gObjEndDate.addText("结束:" + strEndTime);
            gObjEndDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjEndDate);

            string[] sPoints = strDeckFence.Split(';');
            Graph gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Black, 3));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }


            getVibrators();

            sPoints = strVbtFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Blue, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    gObj.setFlag("振捣边界");
                    addGraph(gObj);
                }
            }

            sPoints = strLayerFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Orange, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }
            upDateNonVibr();
            setGrid(strVbtFence);
            pgPanel.Visible = false;
            main.barBtn_Output.Enabled = true;
            reDraw();
        }
        private void DoDepthWork()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 铺层信息表.*,仓面信息.仓面名称,仓面信息.坝段,仓面信息.上下游块,仓面信息.最低高程,仓面信息.最高高程," +
            "仓面信息.振捣边界点,仓面信息.铺层厚度,仓面信息.开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间 " +
            "from 铺层信息表,仓面信息 WHERE 铺层信息表.仓面号=仓面信息.编号 AND 铺层信息表.编号=" + sLayerID + " AND 铺层信息表.仓面号=" + sDeckID;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            DataRow dataRow = dt.Rows[0];
            sDeckName = dataRow["仓面名称"].ToString().Trim();
            sLayerName = dataRow["层编号"].ToString().Trim();
            sDamBlock = sDeckName.Substring(0, sDeckName.LastIndexOf('-'));
           // float fArea = float.Parse(dataRow["剩余未振捣面积"].ToString().Trim());
            float fhMin = float.Parse(dataRow["最低高程"].ToString().Trim());
            float fhMax = float.Parse(dataRow["最高高程"].ToString().Trim());
            string strDeckFence = dataRow["仓面控制点"].ToString().Trim();
            string strVbtFence = dataRow["振捣边界点"].ToString().Trim();
            string strLayerFence = dataRow["层边界控制点"].ToString().Trim();
            string strStartTime = dataRow["开仓时间"].ToString().Trim();
            string strEndTime = dataRow["结束时间"].ToString().Trim();
            sEndTime = strEndTime;
            Graph gObjTitle = new Graph(1, -1);
            gObjTitle.addText(getDeckTitle(sDeckName, sLayerName));
            gObjTitle.setFont(new Font("微软雅黑", 10f));
            alTitleGraph.Add(gObjTitle);
            Graph gObjMaxElv = new Graph(1, -1);
            gObjMaxElv.addText("EL." + fhMax.ToString() + "米");
            gObjMaxElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMaxElv);

            Graph gObjMinElv = new Graph(1, -1);
            gObjMinElv.addText("EL." + fhMin.ToString() + "米");
            gObjMinElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMinElv);

            Graph gObjStartDate = new Graph(1, -1);

            gObjStartDate.addText("开始:" + strStartTime);
            gObjStartDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjStartDate);

            Graph gObjEndDate = new Graph(1, -1);

            gObjEndDate.addText("结束:" + strEndTime);
            gObjEndDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjEndDate);

            string[] sPoints = strDeckFence.Split(';');
            Graph gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Black, 3));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }
            getVibrators();
            sPoints = strVbtFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Blue, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    gObj.setFlag("振捣边界");
                    addGraph(gObj);
                }
            }

            sPoints = strLayerFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Orange, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }

            upDateNonVibr();
            setGrid(strVbtFence);
            pgPanel.Visible = false;
            main.barBtn_Output.Enabled = true;
            reDraw();
            
        }
        private void DoTimeWork()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 铺层信息表.*,仓面信息.仓面名称,仓面信息.坝段,仓面信息.上下游块,仓面信息.最低高程,仓面信息.最高高程," +
            "仓面信息.振捣边界点,仓面信息.铺层厚度,仓面信息.开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间 " +
            "from 铺层信息表,仓面信息 WHERE 铺层信息表.仓面号=仓面信息.编号 AND 铺层信息表.编号=" + sLayerID + " AND 铺层信息表.仓面号=" + sDeckID;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            DataRow dataRow = dt.Rows[0];
            sDeckName = dataRow["仓面名称"].ToString().Trim();
            sLayerName = dataRow["层编号"].ToString().Trim();
            sDamBlock = sDeckName.Substring(0, sDeckName.LastIndexOf('-'));
            //float fArea = float.Parse(dataRow["剩余未振捣面积"].ToString().Trim());
            float fhMin = float.Parse(dataRow["最低高程"].ToString().Trim());
            float fhMax = float.Parse(dataRow["最高高程"].ToString().Trim());
            string strDeckFence = dataRow["仓面控制点"].ToString().Trim();
            string strVbtFence = dataRow["振捣边界点"].ToString().Trim();
            string strLayerFence = dataRow["层边界控制点"].ToString().Trim();
            string strStartTime = dataRow["开仓时间"].ToString().Trim();
            string strEndTime = dataRow["结束时间"].ToString().Trim();
            sEndTime = strEndTime;
            Graph gObjTitle = new Graph(1, -1);
            gObjTitle.addText(getDeckTitle(sDeckName, sLayerName));
            gObjTitle.setFont(new Font("微软雅黑", 10f));
            alTitleGraph.Add(gObjTitle);
            Graph gObjMaxElv = new Graph(1, -1);
            gObjMaxElv.addText("EL." + fhMax.ToString() + "米");
            gObjMaxElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMaxElv);

            Graph gObjMinElv = new Graph(1, -1);
            gObjMinElv.addText("EL." + fhMin.ToString() + "米");
            gObjMinElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMinElv);

            Graph gObjStartDate = new Graph(1, -1);

            gObjStartDate.addText("开始:" + strStartTime);
            gObjStartDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjStartDate);

            Graph gObjEndDate = new Graph(1, -1);

            gObjEndDate.addText("结束:" + strEndTime);
            gObjEndDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjEndDate);

            string[] sPoints = strDeckFence.Split(';');
            Graph gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Black, 3));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }
            getVibrators();
            sPoints = strVbtFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Blue, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    gObj.setFlag("振捣边界");
                    addGraph(gObj);
                }
            }
            sPoints = strLayerFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Orange, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }

            upDateNonVibr();
            setGrid(strVbtFence);
            pgPanel.Visible = false;
            main.barBtn_Output.Enabled = true;
            reDraw();
        }
        private void DoQualifiedWork()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 铺层信息表.*,仓面信息.仓面名称,仓面信息.坝段,仓面信息.上下游块,仓面信息.最低高程,仓面信息.最高高程," +
            "仓面信息.振捣边界点,仓面信息.铺层厚度,仓面信息.开仓状态,仓面信息.仓面控制点,仓面信息.开仓时间,仓面信息.结束时间 " +
            "from 铺层信息表,仓面信息 WHERE 铺层信息表.仓面号=仓面信息.编号 AND 铺层信息表.编号=" + sLayerID + " AND 铺层信息表.仓面号=" + sDeckID;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            DataRow dataRow = dt.Rows[0];
            sDeckName = dataRow["仓面名称"].ToString().Trim();
            sLayerName = dataRow["层编号"].ToString().Trim();
            sDamBlock = sDeckName.Substring(0, sDeckName.LastIndexOf('-'));
          //  float fArea = float.Parse(dataRow["剩余未振捣面积"].ToString().Trim());
            float fhMin = float.Parse(dataRow["最低高程"].ToString().Trim());
            float fhMax = float.Parse(dataRow["最高高程"].ToString().Trim());
            string strDeckFence = dataRow["仓面控制点"].ToString().Trim();
            string strVbtFence = dataRow["振捣边界点"].ToString().Trim();
            string strLayerFence = dataRow["层边界控制点"].ToString().Trim();
            string strStartTime = dataRow["开仓时间"].ToString().Trim();
            string strEndTime = dataRow["结束时间"].ToString().Trim();
            sEndTime = strEndTime;
            Graph gObjTitle = new Graph(1, -1);
            gObjTitle.addText(getDeckTitle(sDeckName, sLayerName));
            gObjTitle.setFont(new Font("微软雅黑", 10f));
            alTitleGraph.Add(gObjTitle);
            Graph gObjMaxElv = new Graph(1, -1);
            gObjMaxElv.addText("EL." + fhMax.ToString() + "米");
            gObjMaxElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMaxElv);

            Graph gObjMinElv = new Graph(1, -1);
            gObjMinElv.addText("EL." + fhMin.ToString() + "米");
            gObjMinElv.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjMinElv);

            Graph gObjStartDate = new Graph(1, -1);

            gObjStartDate.addText("开始:" + strStartTime);
            gObjStartDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjStartDate);

            Graph gObjEndDate = new Graph(1, -1);

            gObjEndDate.addText("结束:" + strEndTime);
            gObjEndDate.setFont(new Font("微软雅黑", 8f));
            alTitleGraph.Add(gObjEndDate);

            string[] sPoints = strDeckFence.Split(';');
            Graph gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Black, 3));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }
            getVibrators();
            sPoints = strVbtFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Blue, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    gObj.setFlag("振捣边界");
                    addGraph(gObj);
                }
            }

            sPoints = strLayerFence.Split(';');
            gObj = new Graph(1, 3);
            gObj.setPen(new Pen(Color.Orange, 1));
            for (int i = 0; i < sPoints.Length; i++)
            {
                string[] sXY = sPoints[i].Split(',');
                if (sXY.Length == 2)
                {
                    gObj.addPoint(new Point(double.Parse(sXY[0]), double.Parse(sXY[1])));
                    addGraph(gObj);
                }
            }

            upDateNonVibr();
            setGrid(strVbtFence);
            pgPanel.Visible = false;
            main.barBtn_Output.Enabled = true;
            reDraw();
        }
        public  void loadLayerData(string sdeckID, string slayerID,string sFlagName)
        {
            if (sDeckID == sdeckID && sLayerID == slayerID && sFlag == sFlagName)
            {
                return;
            }
            clearGraph();
            main.barBtn_Output.Enabled = false;
            sDeckID = sdeckID;
            sLayerID = slayerID;
            sFlag = sFlagName;
            pgPanel.Visible = true;
            System.Threading.Thread th = null;
            sFlag = sFlagName;
            if (sFlag == "OverLay")
            {
                chartCtl.Visible = true;
                th = new Thread(new ThreadStart(this.DoOverLayWork));
            }
            else if(sFlag == "Depth")
            {
                chartCtl.Visible = false;
                th = new Thread(new ThreadStart(this.DoDepthWork));
            }
            else if (sFlag == "Time")
            {
                chartCtl.Visible = false;
                th = new Thread(new ThreadStart(this.DoTimeWork));
            }
            else if (sFlag == "Qualified")
            {
                chartCtl.Visible = false;
                th = new Thread(new ThreadStart(this.DoQualifiedWork));
            }
            th.IsBackground = true;
            th.Start();
        }
        private void computOverLay()
        {
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)//外围区域
                    continue;
                for (int n = 0; n < alNonVibrGraph.Count; n++)
                {
                    NonVibrators nonVibr = (NonVibrators)alNonVibrGraph[n];
                    if (nonVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))//非振捣区域
                        grd.setOverLay(-1);
                }
                for (int p = 0; p < alVibGraph.Count; p++)
                {
                    VibGraph gVibr = (VibGraph)alVibGraph[p];
                    if (gVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))//振捣覆盖
                        grd.setOverLay(1);
                }
            }
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];

                if (grd.getOverLay() >= 2)////振捣重合判断
                {
                    judgeOverLay(m);
                }
                else if (grd.getOverLay() == 0)//振捣间隔判断
                {
                    judgeOverLay(m);
                }
              
            }
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)//外围区域
                    continue;
                if (grd.getOverLay() >= 2 && grd.getTime() > iVibAllowMaxTime)//过度振捣//add by lyl
                {
                    dOverArea += grder.dGridLenth * grder.dGridLenth;
                }
                else if (grd.getOverLay() > 0)//正常振捣
                {
                    dNormalArea += grder.dGridLenth * grder.dGridLenth;
                }
                else if (grd.getOverLay() == 0)//正常未振捣
                {
                    dAbnormalArea += grder.dGridLenth * grder.dGridLenth;
                }
                else if (grd.getOverLay() == -1)//非振捣区域
                {
                    dInvalidArea += grder.dGridLenth * grder.dGridLenth;
                }
            }
            DataTable dataTb = new DataTable();
            SetTable(ref dataTb);
            chartCtl.Series[0].ArgumentDataMember = "统计项";
            chartCtl.Series[0].ValueDataMembers[0] = "值";
            chartCtl.Series[0].DataSource = dataTb;
        }
        private void judgeOverLay(int m)
        {
            Grid grd = (Grid)grder.grdBlock[m];
            if (grd.getOverLay() == 0)
            {
                if (getNearDistVibr(grd.fLX, grd.fTY) < iVibAllowInterval * 0.01)
                {
                    grd.setOverLay(1);
                }
            }
            else if (grd.getOverLay() >=2)
            {
                int iLength = (int)Math.Ceiling(iVibAllowOver * 0.01 / grder.dGridLenth);
                int iCol = grder.iCol;
                int iRow = grder.iRow;
                getOverVibrTime(grd.fLX, grd.fTY);
            }
        }
        private double getNearDistVibr(float fx,float fy)
        {
            double dMinDist = 999999999;
            int flag = -1;
            for (int p = 0; p < alVibGraph.Count; p++)
            {
                VibGraph gVibr = (VibGraph)alVibGraph[p];
                double dDist = gVibr.getDist(fx, fy);
                if(dMinDist>dDist)
                {
                    dMinDist = dDist;
                    flag = p;
                }
            }
            return dMinDist;
        }
        private void getOverVibrTime(float fx, float fy)
        {

        }
        private void computDepth()
        {
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)
                    continue;
                for (int p = 0; p < alVibGraph.Count; p++)
                {
                    VibGraph gVibr = (VibGraph)alVibGraph[p];
                    if (gVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))
                        grd.setDepth(gVibr.fVibDepth);
                }
            }
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)
                    continue;
                if (grd.getDepth() <0)
                    continue;
                int iDepth = (int)((grd.getDepth() - fMinDepth) / ((fMaxDepth - fMinDepth) / iDepthSection));
                iDepth = iDepth < 0 ? 0 : iDepth;
                iDepth = iDepth >= iDepthSection ? (iDepthSection - 1) : iDepth;
                Depth[iDepth]++;
            }    
        }
        private void computTime()
        {
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)
                    continue;
                for (int n = 0; n < alNonVibrGraph.Count; n++)
                {
                    NonVibrators nonVibr = (NonVibrators)alNonVibrGraph[n];
                    if (nonVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))
                        grd.setOverLay(-1);
                }
                for (int p = 0; p < alVibGraph.Count; p++)
                {
                    VibGraph gVibr = (VibGraph)alVibGraph[p];
                    if (gVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))
                        grd.setTime(gVibr.iVibTime);
                }
            }
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)
                    continue;
                if (grd.getTime() < 0)
                    continue;
                int iTime = (int)((grd.getTime() - fMinTime) / ((fMaxTime - fMinTime) / iTimeSection));
                iTime = iTime < 0 ? 0 : iTime;
                iTime = iTime >= iTimeSection ? (iTimeSection - 1) : iTime;
                Time[iTime]++;
            }    
        }
        private void computQualified()
        {
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)
                    continue;
                for (int n = 0; n < alNonVibrGraph.Count; n++)
                {
                    NonVibrators nonVibr = (NonVibrators)alNonVibrGraph[n];
                    if (nonVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))
                        grd.setOverLay(-1);
                }
                for (int p = 0; p < alVibGraph.Count; p++)
                {
                    VibGraph gVibr = (VibGraph)alVibGraph[p];
                   
                    if (gVibr.IsIn(grd.fLX, grd.fTY, grder.dGridLenth))
                    {
                        grd.setTime(gVibr.iVibTime);
                        grd.setDepth(gVibr.fVibDepth);
                        grd.setOverLay(1);
                    }
                }
            }
            for (int p = 0; p < alVibGraph.Count; p++)
            {
                VibGraph gVibr = (VibGraph)alVibGraph[p];
                if (gVibr.iVibTime < iVibAllowMinTime || gVibr.iVibTime > iVibAllowMaxTime)
                {
                    gVibr.setQualified(2);
                    continue;
                }
                else if (gVibr.fVibDepth < iVibAllowDepth)
                {
                    gVibr.setQualified(2);
                    continue;
                }
                gVibr.setQualified(1);
            }
            for (int m = 0; m < grder.grdBlock.Count; m++)
            {
                Grid grd = (Grid)grder.grdBlock[m];
                if (grd.getOverLay() == -9999)//外围区域
                {
                    continue;
                }
                else if (grd.getOverLay() == 0)//未振捣
                {
                    Qualified[0]++;
                    grd.setQualified(0);
                    continue;
                }
                else if (grd.getOverLay() == -1)//内部非振捣区域
                {
                    grd.setQualified(-1);
                    continue;
                }
                if ((grd.getTime() < iVibAllowMinTime || grd.getTime() > iVibAllowMaxTime) && grd.getOverLay()>0)
                {
                    Qualified[2]++;
                    grd.setQualified(2);
                    continue;
                }
                else if ((grd.getDepth() < iVibAllowDepth) && grd.getOverLay() > 0)
                {
                    Qualified[2]++;
                    grd.setQualified(2);
                    continue;
                }
                else if (grd.getOverLay() >2)
                {
                    Qualified[2]++;
                    grd.setQualified(2);
                    continue;
                }
                Qualified[1]++; 
                grd.setQualified(1);
            }
        }
        public  void setGrid(string sPoints)
        {
            grder.clear();
            string[] strPoints = sPoints.Split(';');
            for (int i = 0; i < strPoints.Length; i++)
            {
                string[] strXY = strPoints[i].Split(',');
                if (strXY.Length < 2)
                    continue;
                Point pt = new Point(double.Parse(strXY[0]), double.Parse(strXY[1]));
                grder.addPoint(pt);
            }
            
            grder.setGridPoint();
            if (sFlag == "OverLay")
            {
                computOverLay();
            }
            else if (sFlag == "Depth")
            {
                computDepth();
            }
            else if (sFlag == "Time")
            {
                computTime();
            }
            else if (sFlag == "Qualified")
            {
                computQualified();
            }
        }
        private void getDepthData()
        {
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sSQL = "select 振捣监控点位数据表.* " +
            "from 振捣监控点位数据表 WHERE 仓面号=" + sDeckID + " AND 铺层编号=" + sLayerName;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
        }
        private void SetTable(ref DataTable dataTb)
        {

            dataTb = new DataTable("振捣覆盖统计");

            DataColumn col = new DataColumn("统计项", typeof(string));
            dataTb.Columns.Add(col);

            DataColumn colName = new DataColumn("值", typeof(double));
            dataTb.Columns.Add(colName);


            DataRow dr = dataTb.NewRow();
            dr[0] = "合格振捣";
            dr[1] = dNormalArea;
            dataTb.Rows.Add(dr);
            dr = null;
            dr = dataTb.NewRow();
            dr[0] = "过度振捣";
            dr[1] = dOverArea;
            dataTb.Rows.Add(dr);
            dr = null;
            dr = dataTb.NewRow();
            dr[0] = "未振捣";
            dr[1] = dAbnormalArea;
            dataTb.Rows.Add(dr);
            dr = null;
            dr = dataTb.NewRow();
            dr[0] = "非振捣";
            dr[1] = dInvalidArea;
            dataTb.Rows.Add(dr);
            dr = null;
        }
        public  void getVibrators()
        {
            alVibGraph.Clear();
            fMaxDepth = -99999;
            fMinDepth = 99999;
            PublicDataCls db = new PublicDataCls();
            db.OpenConn();
            string sOrderDepthSQL=" Order by 振捣监控点位数据表.振捣深度 DESC";
            string sOrderTimeSQL = " Order by 振捣监控点位数据表.振捣时长 DESC";
            string sSQL = "select 振捣监控点位数据表.*," +
            "振捣设备基本信息表.编号 as 设备编号,振捣设备基本信息表.型号,振捣设备基本信息表.振动棒数量,振捣设备基本信息表.履带长," +
            "振捣设备基本信息表.履带宽,振捣设备基本信息表.棒头头长," +
            "振捣设备基本信息表.棒头总长,振捣设备基本信息表.振动影响区域,振捣设备基本信息表.使用设备状态," +
            "振捣参数控制标准.振捣深度 AS 容许振捣深度,振捣参数控制标准.容许插入角度偏差,振捣参数控制标准.振捣时间上限,振捣参数控制标准.振捣时间下限," +
            "振捣参数控制标准.振捣区域容许重合值,振捣参数控制标准.振捣区域容许间隔值 " +
            "FROM 振捣监控点位数据表 LEFT OUTER JOIN 振捣设备基本信息表 ON 振捣监控点位数据表.设备编号 = 振捣设备基本信息表.编号 " +
            "LEFT OUTER JOIN 振捣参数控制标准 ON 振捣监控点位数据表.仓面号= 振捣参数控制标准.仓面号 " +
            "WHERE 振捣监控点位数据表.铺层编号=" + sLayerName +
            " AND 振捣监控点位数据表.仓面号=" + sDeckID;
            if(sFlag == "Depth")
                sSQL += sOrderDepthSQL;
            else if (sFlag == "Time")
                sSQL += sOrderTimeSQL;
            DataTable dt = db.ReturnDataTable(sSQL);
            db.CloseConn();
            if (dt == null)//modify by lance 2013-1-20
                return;
            int iCount = dt.Rows.Count;
            if (iCount == 0)
                return;
            for (int i = 0; i < iCount; i++)
            {
                DataRow dataRow = dt.Rows[i];

                float fX = float.Parse(dataRow["X"].ToString().Trim());
                float fY = float.Parse(dataRow["Y"].ToString().Trim());
                string strVibID = dataRow["设备编号"].ToString().Trim();
                string strVibCN = dataRow["型号"].ToString().Trim();
                string strVibFence = dataRow["振动影响区域"].ToString().Trim();
                float fVibAngle = float.Parse(dataRow["振捣方位角"].ToString().Trim());
                float fVibDepth = float.Parse(dataRow["振捣深度"].ToString().Trim());
                int   iVibTime = int.Parse(dataRow["振捣时长"].ToString().Trim());
                iVibAllowDepth = int.Parse(dataRow["容许振捣深度"].ToString().Trim());
                fVibAllowAngle = float.Parse(dataRow["容许插入角度偏差"].ToString().Trim());
                iVibAllowMinTime = int.Parse(dataRow["振捣时间上限"].ToString().Trim());
                iVibAllowMaxTime = int.Parse(dataRow["振捣时间下限"].ToString().Trim());
                iVibAllowOver = int.Parse(dataRow["振捣区域容许重合值"].ToString().Trim());
                iVibAllowInterval = int.Parse(dataRow["振捣区域容许间隔值"].ToString().Trim());
                fMaxDepth = fVibDepth > fMaxDepth ? fVibDepth : fMaxDepth;
                fMinDepth = fVibDepth > fMinDepth ? fMinDepth : fVibDepth;

                fMaxTime = iVibTime > fMaxTime ? iVibTime : fMaxTime;
                fMinTime = iVibTime > fMinTime ? fMinTime : iVibTime;
                
                string[] sPoints = strVibFence.Split(';');
                VibGraph gObj = new VibGraph(1, 31);
                gObj.setPen(new Pen(Color.FromArgb(160, ColorTranslator.FromWin32(Properties.Settings.Default.ep_color8)), 1));
                gObj.setParam(fVibDepth, fVibAngle, iVibTime);
                for (int j = 0; j < sPoints.Length; j++)
                {
                    string[] sXY = sPoints[j].Split(',');
                    if (sXY.Length == 2)
                    {
                        gObj.addPoint(angleTranslate(fX, fY, double.Parse(sXY[0]), double.Parse(sXY[1]), fVibAngle * Math.PI / 180));
                    }
                }
                gObj.setRegion();
                alVibGraph.Add(gObj);
            }
        }
        private Point angleTranslate(double dfx, double dfy, double dx, double dy, double fAngle)
        {
            double sin = Math.Sin(fAngle);
            double cos = Math.Cos(fAngle);

            double x = dx * cos - dy * sin;
            double y = dx * sin + dy * cos;
            return new Point(dfx + x, dfy + y);
        }
        public  void setMapMode(int imapMode)
        {
            m_MapMode = imapMode;
            m_OldMapMode = m_MapMode;
            if (m_MapMode == 1)//放大
            {
                this.Cursor = Cursors.Arrow;
            }
            else if (m_MapMode == 2)//缩小
            {
                this.Cursor = Cursors.Arrow;
            }
            else if (m_MapMode == 3)//拖动
            {
                this.Cursor = Cursors.Hand;
            }
            else if (m_MapMode == 4)//全图
            {
                this.Cursor = Cursors.Arrow;
            }
            else if (m_MapMode == 5)//全图
            {
                this.Cursor = Cursors.Cross;
            }
        }
        public  void reDraw()
        {
            m_Extent.reSet();
            for (int i = 0; i < alGraph.Count; i++)
            {
                Graph gObj = (Graph)alGraph[i];
                if (gObj.sFlag == "振捣边界")
                {
                    m_Extent.upDate(gObj.extent);
                    m_MapAllExtent = m_Extent;
                }
            }
            Canvas.Refresh();
        }
        private string getDefaultFileName()
        {
            string sTime = "";
            if (sEndTime != null)
            {
                string[] sTimes = sEndTime.Split(' ');
                if (sTimes.Length == 2)
                {
                    sTime = sTimes[0];
                }
                sTime = sTime.Replace("/", "-");
            }
            string sFileName = sDeckName + "_第" + sLayerName + "铺层_" + sTime + "_";
            if (sFlag == "OverLay")
            {
                sFileName+="振捣压盖";
            }
            else if (sFlag == "Depth")
            {
               sFileName+="振捣深度";
            }
            else if (sFlag == "Time")
            {
               sFileName+="振捣时间";
            }
            else if (sFlag == "Qualified")
            {
                sFileName += "有效振捣";
            }
            return sFileName;
        }
        public  void exportImg()
        {
            if (sFlag == "OverLay")
            {
                main.saveFileDialog.Title = "输出振捣覆盖图形报表";
            }
            else if (sFlag == "Depth")
            {
                main.saveFileDialog.Title = "输出振捣深度图形报表";
            }
            else if (sFlag == "Time")
            {
                main.saveFileDialog.Title = "输出振捣时间图形报表";
            }
            main.saveFileDialog.Filter = "jpg|*.jpg|png|*.jpg|bmp|*.bmp";//保存为txt文件
            main.saveFileDialog.FileName=getDefaultFileName();
            
            if (main.saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fname = main.saveFileDialog.FileName;//要保存的文件


                reDraw();
                Rectangle rect = Canvas.ClientRectangle;
                Bitmap bitmap = new Bitmap(rect.Width, rect.Height);
                //获得窗口屏幕大小  
                
                Canvas.DrawToBitmap(bitmap, rect);
                if (sFlag == "OverLay")
                {
                    rect.X = this.Canvas.Width - 270;
                    rect.Y = this.Canvas.Height - 220;
                    rect.Width = 270;
                    rect.Height = 220;
                    chartCtl.DrawToBitmap(bitmap, rect);
                }


                Graphics g = Graphics.FromImage(bitmap);
                DateTime now = System.DateTime.Now;

                string sExportDate = "出图时间:" + now.ToString("yyyy-M-d H:m:s");
                Font ft = new Font("微软雅黑", 8f);
                SizeF sizeF1 = g.MeasureString(sExportDate, ft);
                g.DrawString(sExportDate, ft, Brushes.Black,
                                    40, m_hScreen - 30);//写标题
                g.Dispose();
                bitmap.Save(fname);
                bitmap.Dispose();
                MessageBox.Show("图形报表保存成功！", "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public  void exportImg(string fileName)
        {
            
            if (sFlag == "OverLay")
            {
                main.saveFileDialog.Title = "输出振捣覆盖图形报表";
            }
            else if (sFlag == "Depth")
            {
                main.saveFileDialog.Title = "输出振捣深度图形报表";
            }
            else if (sFlag == "Time")
            {
                main.saveFileDialog.Title = "输出振捣时间图形报表";
            }
 
            reDraw();
            Rectangle rect = Canvas.ClientRectangle;
            Bitmap bitmap = new Bitmap(rect.Width, rect.Height);
                //获得窗口屏幕大小  

            Canvas.DrawToBitmap(bitmap, rect);
            if (sFlag == "OverLay")
            {
               rect.X = this.Canvas.Width - 270;
               rect.Y = this.Canvas.Height - 220;
               rect.Width = 270;
               rect.Height = 220;
               chartCtl.DrawToBitmap(bitmap, rect);
            }


            Graphics g = Graphics.FromImage(bitmap);
            
            string sNow=System.DateTime.Now.ToString("yyyy/M/d H:m:s");
            string sExportDate = "出图时间:" + sNow;
            Font ft = new Font("微软雅黑", 8f);
            SizeF sizeF1 = g.MeasureString(sExportDate, ft);
            g.DrawString(sExportDate, ft, Brushes.Black,
                                    40, m_hScreen - 30);//写标题
            g.Dispose();
            bitmap.Save(fileName);
            bitmap.Dispose();
 
         }
        
        #region **************仓面坐标转换操作函数**************
        public int DLtoVL(double l)
        {
            return (int)(l / m_Blc);                                //返回实际坐标表示的长度值
        }
        public double VLtoDL(int l)
        {
            return (double)(l * m_Blc);                             //返回逻辑坐标表示的长度值
        }
        public void VPtoDP(int x, int y, ref double X, ref double Y) //将逻辑坐标转换成实际坐标
        {
            X = m_xStart + x * m_Blc;
            Y = m_yStart + m_Blc * (m_hScreen - y);
        }
        public double VPtoDPX(int x) //将逻辑坐标转换成实际坐标
        {
            return m_xStart + x * m_Blc;
        }
        public double VPtoDPY(int y) //将逻辑坐标转换成实际坐标
        {
            return m_yStart + m_Blc * (m_hScreen - y);
        }
        public void DPtoVP(double x, double y, ref int X, ref int Y) //将实际坐标换成逻辑坐标转
        {
            X = (int)((x - m_xStart) / m_Blc);
            Y = m_hScreen - (int)((y - m_yStart) / m_Blc);
            //Y = (int)((m_yStart - y) / blc);
        }
        public int DPtoVPX(double x) //将实际坐标换成逻辑坐标转
        {
            return (int)((x - m_xStart) / m_Blc);
        }
        public int DPtoVPY(double y) //将实际坐标换成逻辑坐标转
        {
            return m_hScreen - (int)((y - m_yStart) / m_Blc);
            //return (int)((m_yStart - y) / blc);
        }
        #endregion
        #region **************绘图函数**************
        private void DrawNonVibrGraph(ref Graphics g)//画正式非振捣区域——多个图元
        {
            for (int k = 0; k < alNonVibrGraph.Count; k++)
            {
                NonVibrators nonVibr = (NonVibrators)alNonVibrGraph[k];
                int iLength = nonVibr.alPlgGraph.Count;
                System.Drawing.Point[] pts = new System.Drawing.Point[iLength];
                for (int i = 0; i < nonVibr.alPlgGraph.Count; i++)
                {
                    Point pt = (Point)nonVibr.alPlgGraph[i];
                    int iVPX = DPtoVPX(pt.getX());
                    int iVPY = DPtoVPY(pt.getY());
                    pts[i] = new System.Drawing.Point(iVPX, iVPY);
                }
                if (iLength > 2)
                {
                    //Color cl = Color.FromArgb(nonVibr.iColor);
                    SolidBrush opaqueBrush = new SolidBrush(Color.FromArgb(255, 132, 193, 255));
                    g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                    /*  opaqueBrush = new SolidBrush(SystemColors.HotTrack);
                    for (int j = 0; j < pts.Length; j++)
                     {
                        g.FillEllipse(opaqueBrush, pts[j].X - 5, pts[j].Y - 5, 10, 10);
                     }   //不顶点*/
                    opaqueBrush.Dispose();
                }
                pts = null;
                /*Font ft = new Font("微软雅黑", 9f);
                SizeF sizeF1 = g.MeasureString(nonVibr.sName, ft);
                g.DrawString(nonVibr.sName, ft, Brushes.Blue,
                                       DPtoVPX(nonVibr.dCenterX), DPtoVPY(nonVibr.dCenterY));
            
                 */
            }
        }
        private void Canvas_Paint(object sender, PaintEventArgs e)
        {
            updateMapExtent();
            if (!bReady)
                return;
            Graphics g = e.Graphics; //创建画板,这里的画板是由Canvas提供的.
            g.Clear(Color.White);

            #region **************画刻度**************
          
            #endregion
            #region **************画仓面**************
            for (int i = 0; i < alGraph.Count; i++)
            {
                Graph gObj = (Graph)alGraph[i];
                if (gObj.sFlag != "振捣边界")
                    continue;
                switch (gObj.type)
                {
                    case 3://面 
                        {
                            int iLength = gObj.alPoint.Count;
                            System.Drawing.Point[] pts = new System.Drawing.Point[iLength];
                            for (int j = 0; j < iLength; j++)
                            {
                                int iVPX = DPtoVPX(gObj.getPointX(j));
                                int iVPY = DPtoVPY(gObj.getPointY(j));
                                pts[j] = new System.Drawing.Point(iVPX, iVPY);
                            }
                            SolidBrush opaqueBrush = null;
                            if (sFlag == "OverLay")
                            {
                                opaqueBrush = new SolidBrush(Color.FromArgb(0xFF, 0xCC, 0x66));
                                g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                                opaqueBrush.Dispose(); 
                            }
                            else if (sFlag == "Depth")
                            {
                                
                            }
                            else if (sFlag == "Time")
                            {
                                
                            }
                            else if (sFlag == "Qualified")
                            {
                                opaqueBrush = new SolidBrush(Color.FromArgb(0xFF, 0xCC, 0x66));
                                g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                                opaqueBrush.Dispose(); 
                            }
                            g.DrawPolygon(new Pen(SystemColors.GrayText, 1), pts);
                            pts = null;
                            break;
                        }
                    default:
                        break;
                }
            }
             #endregion
            #region **************画振捣点位**************
            for (int i = 0; i < alVibGraph.Count; i++)
            {
                VibGraph gObj = (VibGraph)alVibGraph[i];
                switch (gObj.type)
                {
                    case 31://填充面 
                        {

                            int iLength = gObj.alPoint.Count;
                            System.Drawing.Point[] pts = new System.Drawing.Point[iLength];
                            for (int j = 0; j < iLength; j++)
                            {
                                int iVPX = DPtoVPX(gObj.getPointX(j));
                                int iVPY = DPtoVPY(gObj.getPointY(j));
                                pts[j] = new System.Drawing.Point(iVPX, iVPY);
                            }
                            SolidBrush opaqueBrush = null;
                            if (sFlag == "OverLay")
                            {
                                opaqueBrush = new SolidBrush(Color.FromArgb(0x99, 0xCC, 0x00));
                            }
                            else if (sFlag == "Depth")
                            {
                                int iColor = (int)(200 * (gObj.fVibDepth - fMinDepth) / iDepthSection);
                                iColor = iColor > 255 ? 255 : iColor;
                                iColor = iColor < 0 ? 0 : iColor;
                                opaqueBrush = new SolidBrush(Color.FromArgb(255, 0, iColor, 255));
                            }
                            else if (sFlag == "Time")
                            {
                                int iColor = (int)(200 * (gObj.iVibTime - fMinTime) / iTimeSection);
                                iColor = iColor > 255 ? 255 : iColor;
                                iColor = iColor < 0 ? 0 : iColor;
                                opaqueBrush = new SolidBrush(Color.FromArgb(255, 0, 255,iColor));
                            }
                            else if (sFlag == "Qualified")
                            {
                                Color color = Color.FromArgb(0xFF, 0xCC, 0x66);
                                 if (gObj.iVibQualified == 1)
                                 {
                                    color=Color.FromArgb(0x99, 0xCC, 0x00);
                                 }
                                 else if (gObj.iVibQualified == 2)
                                {
                                    color=Color.FromArgb(0xFF, 0x66, 0x00);
                                }
                                else if (gObj.iVibQualified == 0)
                                {
                                    color=Color.FromArgb(0xFF, 0xCC, 0x66);
                                }
                                
                                opaqueBrush = new SolidBrush(color);
                            }
                            g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                            pts = null;
                            break;
                        }
                    default:
                        break;
                }
            }
            #endregion 
           
            #region **************画统计格网**************
            if (sFlag == "OverLay")
            {
                if (grder != null && grder.grdBlock != null)
                {
                    for (int p = 0; p < grder.grdBlock.Count; p++)
                    {
                        Grid grd = (Grid)grder.grdBlock[p];
                        if (grd == null)
                            continue;

                        if (grd.getOverLay() >= 2 && grd.getTime() > iVibAllowMaxTime)
                        {
                            System.Drawing.Point[] pts = new System.Drawing.Point[5];
                            int iVPX = DPtoVPX(grd.fLX - grder.dGridLenth / 2);
                            int iVPY = DPtoVPY(grd.fTY + grder.dGridLenth / 2);
                            pts[0] = new System.Drawing.Point(iVPX, iVPY);
                            iVPX = DPtoVPX(grd.fLX + grder.dGridLenth);
                            iVPY = DPtoVPY(grd.fTY);
                            pts[1] = new System.Drawing.Point(iVPX, iVPY);
                            iVPX = DPtoVPX(grd.fLX + grder.dGridLenth);
                            iVPY = DPtoVPY(grd.fTY - grder.dGridLenth);
                            pts[2] = new System.Drawing.Point(iVPX, iVPY);
                            iVPX = DPtoVPX(grd.fLX);
                            iVPY = DPtoVPY(grd.fTY - grder.dGridLenth);
                            pts[3] = new System.Drawing.Point(iVPX, iVPY);
                            pts[4] = pts[0];
                            SolidBrush opaqueBrush = null;
                            opaqueBrush = new SolidBrush(Color.FromArgb(0xFF, 0x66, 0x00));
                            g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                            pts = null;
                        }
                        /* else if (grd.getOverLay() > 0)
                         {

                             SolidBrush opaqueBrush = null;
                             opaqueBrush = new SolidBrush(Color.FromArgb(0x99, 0xCC, 0x00));
                             g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                             pts = null;
                         }
                         else if (grd.getOverLay() == 0)
                         {

                             SolidBrush opaqueBrush = null;
                             opaqueBrush = new SolidBrush(Color.FromArgb(0xFF, 0xCC, 0x66));
                             g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                             pts = null;
                         }
                         else if (grd.getOverLay() == -1)
                         {

                             SolidBrush opaqueBrush = null;
                             opaqueBrush = new SolidBrush(Color.FromArgb(255, 132, 193, 255));
                             g.FillPolygon(opaqueBrush, pts, FillMode.Alternate);
                             pts = null;
                         }*/
                    }
                }
                
            }
            #endregion 
            
            #region **************画无效区域**************
            DrawNonVibrGraph(ref g);
            #endregion
            #region **************画标题**************
            string sTitle = "振捣图形报告";
            if (sFlag == "OverLay")
            {
                sTitle = "振捣覆盖图形报告";
            }
            else if (sFlag == "Depth")
            {
                sTitle = "振捣深度图形报告";
            }
            else if (sFlag == "Time")
            {
                sTitle = "振捣时间图形报告";
            }
            else if (sFlag == "Qualified")
            {
                sTitle = "有效振捣图形报告";
            }
            Font ft = new Font("微软雅黑", 16f, FontStyle.Bold);
            SizeF sizeF1 = g.MeasureString(sTitle, ft);
            g.DrawString(sTitle, ft, Brushes.Black,
                                m_wScreen / 2 - sizeF1.Width / 2, 20);//写标题

            if (alTitleGraph.Count >= 2)//写子标题信息
            {
                g.DrawLine(new Pen(SystemColors.GrayText, 2), 30, 55, m_wScreen - 30, 55);

                Graph gObjSubTitle = (Graph)alTitleGraph[0];
                Graph gObjMaxEl = (Graph)alTitleGraph[1];
                Graph gObjMinEl = (Graph)alTitleGraph[2];
                Graph gObjStartDate = (Graph)alTitleGraph[3];
                Graph gObjEndDate = (Graph)alTitleGraph[4];
                g.DrawString(gObjSubTitle.sText, gObjSubTitle.font, Brushes.Black,
                                    m_wScreen / 2 - g.MeasureString(gObjSubTitle.sText, gObjSubTitle.font).Width / 2, 60);
                g.DrawString(gObjMaxEl.sText, gObjMaxEl.font, Brushes.Black, 35, 55);
                g.DrawString(gObjMinEl.sText, gObjMinEl.font, Brushes.Black, 35, 70);
                float fWidth1 = g.MeasureString(gObjStartDate.sText, gObjStartDate.font).Width;
                float fWidth2 = g.MeasureString(gObjEndDate.sText, gObjEndDate.font).Width;
                float fWidth = fWidth1 > fWidth2 ? fWidth1 : fWidth2;
                g.DrawString(gObjStartDate.sText, gObjStartDate.font, Brushes.Black,
                                    m_wScreen - 35 - fWidth, 55);
                g.DrawString(gObjEndDate.sText, gObjEndDate.font, Brushes.Black,
                                    m_wScreen - 35 - fWidth, 70);
            }
            #endregion
            #region **************画图例**************
            if (sFlag == "Depth")
            {
                int iHeight = iDepthSection * 25;
                int iColorSection = (int)(200 / iDepthSection);
                g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 271, m_hScreen - 221, 270, 220);
                Font font = new Font("微软雅黑", 12f, FontStyle.Bold);
                SizeF sizeLengedF = g.MeasureString("振捣深度统计", font);
                g.DrawString("振捣深度统计", font, Brushes.Black,
                                    m_wScreen - (270) / 2 - sizeLengedF.Width / 2, m_hScreen - 200);
                Font fontSection = new Font("微软雅黑", 9f);
                Font fontValue = new Font("微软雅黑", 8f,FontStyle.Bold);
                string sDepth = "";
                
                for (int i = 1; i <= iDepthSection; i++)
                {
                    SolidBrush opaqueBrush = new SolidBrush(Color.FromArgb(255, 0, iColorSection * i, 255));
                    g.FillRectangle(opaqueBrush, m_wScreen - 170, m_hScreen - 25 * i - 25, 50, 25);
                    /*g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 150, m_hScreen - 25 * i, 40, 25);*/
                    
                    float fDepth = (fMinDepth + (i - 1) * (fMaxDepth - fMinDepth) / iDepthSection);
                    sDepth=fDepth.ToString("#0.##");
                    g.DrawString(sDepth, fontSection, Brushes.Black,
                                        m_wScreen - 120, m_hScreen - 26*iDepthSection + i*25-55);

                    float fTotleProp = (Depth[0] + Depth[1] + Depth[2] + Depth[3] + Depth[4]);
                    if (fTotleProp > 0)
                    {
                        float fProp = Depth[i - 1] / fTotleProp * 100;
                        string sProp = fProp.ToString("#0.##") + "%";
                        g.DrawString(sProp, fontValue, Brushes.White,
                                            m_wScreen - 165, m_hScreen - 25 * i - 20);
                    }
                    opaqueBrush.Dispose();
                }
                sDepth = fMaxDepth.ToString("#0.##");
                g.DrawString(sDepth, fontSection, Brushes.Black,
                                    m_wScreen - 120, m_hScreen - 34);
            }
            else if (sFlag == "Time")
            {
                int iHeight = iTimeSection * 25;
                int iColorSection = (int)(200 / iTimeSection);
                g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 271, m_hScreen - 221, 270, 220);
                Font font = new Font("微软雅黑", 12f, FontStyle.Bold);
                SizeF sizeLengedF = g.MeasureString("振捣时间统计", font);
                g.DrawString("振捣时间统计", font, Brushes.Black,
                                    m_wScreen - (270) / 2 - sizeLengedF.Width / 2, m_hScreen - 200);
                Font fontSection = new Font("微软雅黑", 9f);
                Font fontValue = new Font("微软雅黑", 8f, FontStyle.Bold);
                string sTime = "";

                for (int i = 1; i <= iTimeSection; i++)
                {
                    SolidBrush opaqueBrush = new SolidBrush(Color.FromArgb(255, 0, 255, iColorSection * i));
                    g.FillRectangle(opaqueBrush, m_wScreen - 170, m_hScreen - 25 * i - 25, 50, 25);
                    /*g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 150, m_hScreen - 25 * i, 40, 25);*/

                    float fTime = (fMinTime + (i - 1) * (fMaxTime - fMinTime) / iTimeSection);
                    sTime = fTime.ToString("#0.##");
                    g.DrawString(sTime, fontSection, Brushes.Black,
                                        m_wScreen - 120, m_hScreen - 26 * iTimeSection + i * 25 - 55);

                    float fTotleProp = (Time[0] + Time[1] + Time[2] + Time[3] + Time[4]);
                    if (fTotleProp > 0)
                    {
                        float fProp = Time[i - 1] / fTotleProp * 100;
                        string sProp = fProp.ToString("#0.##") + "%";
                        g.DrawString(sProp, fontValue, Brushes.White,
                                            m_wScreen - 165, m_hScreen - 25 * i - 20);
                    }
                    opaqueBrush.Dispose();
                }
                sTime = fMaxTime.ToString("#0.##");
                g.DrawString(sTime, fontSection, Brushes.Black,
                                    m_wScreen - 120, m_hScreen - 34);
            }
            else if (sFlag == "Qualified")
            {
                int iHeight = iQualifiedSection * 25;
                int iColorSection = (int)(200 / iQualifiedSection);
                g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 271, m_hScreen - 161, 270, 160);
                Font font = new Font("微软雅黑", 12f, FontStyle.Bold);
                SizeF sizeLengedF = g.MeasureString("有效振捣统计", font);
                g.DrawString("有效振捣统计", font, Brushes.Black,
                                    m_wScreen - (270) / 2 - sizeLengedF.Width / 2, m_hScreen - 140);
                Font fontSection = new Font("微软雅黑", 9f);
                Font fontValue = new Font("微软雅黑", 8f, FontStyle.Bold);
                string sTime = "";
                for (int i = 1; i <= iQualifiedSection; i++)
                {
                    
                    
                    /*g.DrawRectangle(new Pen(Color.Gray, 1),
                        m_wScreen - 150, m_hScreen - 25 * i, 40, 25);*/
                    string sQualified = "";
                    SolidBrush opaqueBrush = null;
                    if (i == 1)
                    {
                        sQualified = "未振捣";
                        opaqueBrush = new SolidBrush( Color.FromArgb(0xFF, 0xCC, 0x66));
                    }
                    else if (i == 2)
                    {
                        sQualified = "有效振捣";
                        opaqueBrush = new SolidBrush(Color.FromArgb(0x99, 0xCC, 0x00));
                    }
                    else if (i == 3)
                    {
                        sQualified = "无效振捣";
                        opaqueBrush = new SolidBrush(Color.FromArgb(0xFF, 0x66, 0x00));
                    }
                    g.FillRectangle(opaqueBrush, m_wScreen - 170, m_hScreen - 25 * i - 25, 50, 25);
                    opaqueBrush.Dispose();

                    float fTotleProp = (Qualified[0] + Qualified[1] + Qualified[2]);
                    if (fTotleProp > 0)
                    {
                        float fProp = Qualified[i - 1] / fTotleProp * 100;
                        string sProp = fProp.ToString("#0.##") + "%";

                        g.DrawString(sProp, fontValue, Brushes.White,
                                            m_wScreen - 165, m_hScreen - 25 * i - 20);
                    }
                    g.DrawString(sQualified, fontSection, Brushes.Black,
                                       m_wScreen - 120, m_hScreen - 25 * i - 20);
                }
            }
            #endregion    
           
             
        }
        #endregion
        #region **************事件响应函数**************
        private void Canvas_MouseEnter(object sender, EventArgs e)
        {
            Canvas.Focus();
        }
        private void Canvas_MouseDown(object sender, MouseEventArgs e)
        {
            if (!bReady)
                return;
            if (e.Button == MouseButtons.Middle)
            {
                m_bLBtnDown = true;
                m_Point1.dX = e.X;
                m_Point1.dY = e.Y;
                m_OldMapMode = m_MapMode;
                m_MapMode = 3;
            }
            else if (m_MapMode < 4)
            {
                m_bLBtnDown = true;
                m_Point1.dX = e.X;
                m_Point1.dY = e.Y;
            }
        }
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            int iX = e.X;
            int iY = e.Y;
            double dX = VPtoDPX(iX);
            double dY = VPtoDPY(iY);
            main.upDateXYInfo(dX, dY);
            if (!bReady)
                return;
            if (m_bLBtnDown == true && m_MapMode < 3)
            {
                m_Point2.dX = iX;
                m_Point2.dY = iY;
                Canvas.Refresh();
            }
            else if (m_bLBtnDown == true && m_MapMode == 3)
            {
                m_Point2.dX = iX;
                m_Point2.dY = iY;
                m_Extent.move(VPtoDPX((int)m_Point1.dX) - VPtoDPX((int)m_Point2.dX),
                    VPtoDPY((int)m_Point1.dY) - VPtoDPY((int)m_Point2.dY));
                m_Point1.dX = m_Point2.dX;
                m_Point1.dY = m_Point2.dY;
                Canvas.Refresh();
            }
        }
        public  void Canvas_MouseWheel(object sender, MouseEventArgs e)
        {
            if (!bReady)
                return;
            if (e.Delta > 0)//e.Delta > 0时鼠标滚轮是向上滚动，
            {
                double sx = 0;
                double sy = 0;
                VPtoDP(e.X, e.Y, ref sx, ref sy);
                m_Extent.upDate(m_Extent.dMinX - m_Extent.getWidth() * 0.05, m_Extent.dMinY - m_Extent.getHeight() * 0.05
                    , m_Extent.dMaxX + m_Extent.getWidth() * 0.05, m_Extent.dMaxY + m_Extent.getHeight() * 0.05);
                updateMapExtent();
                /*
                                int ix=0;
                                int iy=0;
                                DPtoVP(sx, sy, ref ix, ref iy);
                                int iLengthx = ix - e.X;
                                int iLengthy = iy - e.Y;
                                double dX = VLtoDL(iLengthx);
                                double dY = VLtoDL(iLengthy);
                
                                m_Extent.move(dX,dY);
                                */
                Canvas.Refresh();
            }
            else if (e.Delta < 0)//e.Delta < 0时鼠标滚轮向下滚动。
            {
                double sx = 0;
                double sy = 0;
                VPtoDP(e.X, e.Y, ref sx, ref sy);
                m_Extent.upDate(m_Extent.dMinX + m_Extent.getWidth() * 0.05,
                    m_Extent.dMinY + m_Extent.getHeight() * 0.05, m_Extent.dMaxX - m_Extent.getWidth() * 0.05,
                        m_Extent.dMaxY - m_Extent.getHeight() * 0.05);
                updateMapExtent();
                /*    int ix = 0;
                    int iy = 0;
                    DPtoVP(sx, sy, ref ix, ref iy);
                    int iLengthx = ix-e.X;
                    int iLengthy = iy - e.Y;
                    double dX = VLtoDL(iLengthx);
                    double dY = VLtoDL(iLengthy);

                    m_Extent.move(dX, dY);
                    */
                Canvas.Refresh();
            }
            else if (e.Delta == 0)
            {
                m_bLBtnDown = true;
                m_Point1.dX = e.X;
                m_Point1.dY = e.Y;
                // m_MapMode = 4;
                m_OldMapMode = m_MapMode;
                m_MapMode = 3;
            }

        }
        private void Canvas_MouseUp(object sender, MouseEventArgs e)
        {

            if (!bReady)
                return;
            if (e.Button == MouseButtons.Middle)
            {
                m_bLBtnDown = false;
                m_MapMode = m_OldMapMode;
            }
            if (m_bLBtnDown == true && m_MapMode < 3)
            {
                m_Point2.dX = e.X;
                m_Point2.dY = e.Y;
                m_bLBtnDown = false;

                if (Math.Abs(m_Point1.dX - m_Point2.dX) < 50 && Math.Abs(m_Point1.dX - m_Point2.dX) < 50)
                {
                    m_bLBtnDown = false;
                    return;
                }
                if (m_MapMode == 1)
                    m_Extent.upDate(VPtoDPX((int)m_Point1.dX), VPtoDPY((int)m_Point1.dY),
                        VPtoDPX((int)m_Point2.dX), VPtoDPY((int)m_Point2.dY));
                else if (m_MapMode == 2)
                {
                    double dX1 = VPtoDPX((int)m_Point1.dX);
                    double dY1 = VPtoDPY((int)m_Point1.dY);
                    double dX2 = VPtoDPX((int)m_Point2.dX);
                    double dY2 = VPtoDPY((int)m_Point2.dY);
                    double dCenterX = (dX1 + dX2) / 2;
                    double dCenterY = (dY1 + dY2) / 2;
                    double dWidth = m_Extent.getWidth();
                    double dHeight = m_Extent.getHeight();
                    m_Extent.upDate(dCenterX - dWidth / 2 * 1, dCenterY - dHeight / 2 * 1,
                        dCenterX + dWidth / 2 * 1, dCenterY + dHeight / 2 * 1);
                }
                Canvas.Refresh();
            }
            else if (m_bLBtnDown == true && m_MapMode == 3)
            {
                m_Point2.dX = e.X;
                m_Point2.dY = e.Y;

                m_Extent.move(VPtoDPX((int)m_Point1.dX) - VPtoDPX((int)m_Point2.dX),
                    VPtoDPY((int)m_Point1.dY) - VPtoDPY((int)m_Point2.dY));
                Canvas.Refresh();
            }
            m_bLBtnDown = false;
        }
        private void Canvas_Resize(object sender, EventArgs e)
        {
            Canvas.Refresh();
            pgPanel.SetBounds(this.Canvas.Width / 2 - 100, this.Canvas.Height / 2 - 33, 200, 66);
            chartCtl.SetBounds(this.Canvas.Width - 270, this.Canvas.Height - 220, 270, 220);
        }
        #endregion
    }
}